package musicstore.com.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import musicstore.com.dao.AlbumDao;
import musicstore.com.dao.GenreDao;
import musicstore.com.dao.impl.AlbumDaoImpl;
import musicstore.com.dao.impl.GenreDaoImpl;
import musicstore.com.entity.Album;
import musicstore.com.entity.Genre;

public class AlbumDetailServlet extends HttpServlet {

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		String user = request.getParameter("user");
		int gid = 0;
		int id = 0;
		if(request.getParameter("gid")!=null && !request.getParameter("gid").isEmpty()){
			gid  = Integer.parseInt(request.getParameter("gid"));
		}
		if(request.getParameter("id")!=null && !request.getParameter("id").isEmpty()){
			id  = Integer.parseInt(request.getParameter("id"));
		}
		GenreDao genreDao = new GenreDaoImpl();
		List<Genre> genreList = genreDao.getGenreList();
		AlbumDao albumDao= new AlbumDaoImpl();
		Album album = albumDao.getAlbumInfoByIdAndGenreID(id);
		
		request.setAttribute("genre", genreList);
		request.setAttribute("album", album);
		
		request.getRequestDispatcher("AlbumDetail.jsp").forward(request, response);
		
	}

}
